package yf.mall.dao;

import com.yf.dao.BaseDao;
import yf.mall.entity.CartEntity;
import yf.mall.vo.CartVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 购物车Dao
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Fri Aug 23 11:38:38 CST 2019
 */
@Mapper
public interface CartDao extends BaseDao<CartEntity> {

    List<CartVo> findByUserId(Long userId);

    /**
     * 找到某个用户某个产品的购物车
     *
     * @param goodsId
     * @param skuName 如果为空就不查询
     * @return
     */
    CartEntity findByUserIdAndGoodsIdWidthSkuName(@Param("userId") Long userId, @Param("goodsId") Long goodsId, @Param("skuName") String skuName);


    List<CartEntity> findByUserIdAndCartIds(@Param("userId") Long userId, @Param("cartIds") List<Long> cartIds);

    void changeAllSelectedByUser(@Param("userId") Long userId, @Param("selected") boolean selected);

    List<CartEntity> findByUserIdWithSelected(Long userId);

    //移除XX所有选择了购物车
    void deleteSelected(Long userId);

    //清空购物车
    void deleteAll(long userId);

}
